package com.mz.ozy.adapter;

import android.text.TextUtils;
import android.util.Log;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;
import com.mz.ozy.bean.ObShopBean;
import com.mz.ozy.utils.glideUtils.GlideUtils;
import com.mz.ozy.widget.CustomRoundAngleImageView;

import java.util.List;

//package com.mz.ozy.adapter;
//
///**
// * @author wansong
// * @description:
// * @date :2020/9/24 17:20
// */
//
//import android.content.Context;
//import android.text.TextUtils;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.ImageView;
//import android.widget.TextView;
//
//import androidx.annotation.NonNull;
//import androidx.recyclerview.widget.RecyclerView;
//import androidx.recyclerview.widget.StaggeredGridLayoutManager;
//
//import com.chad.library.adapter.base.BaseQuickAdapter;
//import com.chad.library.adapter.base.BaseViewHolder;
//import com.mz.ozy.R;
//import com.mz.ozy.bean.GoodsListBean;
//import com.mz.ozy.bean.HomeMerBean;
//import com.mz.ozy.bean.ObShopBean;
//import com.mz.ozy.utils.glideUtils.GlideUtils;
//import com.mz.ozy.widget.CustomRoundAngleImageView;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import butterknife.BindView;
//import butterknife.ButterKnife;
//import retrofit2.http.HEAD;
//
//import static androidx.recyclerview.widget.RecyclerView.*;
//
///**
// * @author lifeStyle on 2020/4/3 0003.
// */
public class ObShopAdapter extends BaseQuickAdapter<ObShopBean.PBean.PageItemsBean, BaseViewHolder> {


    public ObShopAdapter(List<ObShopBean.PBean.PageItemsBean> data) {
        super(R.layout.item_search_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ObShopBean.PBean.PageItemsBean item) {
        helper.setText(R.id.tv_goods_name, item.getTradename());
        helper.setText(R.id.tv_benifit_kind, item.getDescribed());
        helper.setVisible(R.id.tv_unit_price, false);
        helper.setText(R.id.tv_goods_price, item.getPrice() + " 欧花");

        CustomRoundAngleImageView ivGoodsPic = helper.getView(R.id.iv_goods_pic);
        String imgUrl = "";
        if (!TextUtils.isEmpty(item.getImg_zt())) {
            final String[] img_arr = item.getImg_zt().trim().split(",");
            if (img_arr.length > 0) {
                imgUrl = img_arr[0];
            }
        }
        GlideUtils.loadRoundImg(mContext, ivGoodsPic, imgUrl, R.mipmap.default_foods_icon, 4);

        helper.addOnClickListener(R.id.ll_item_view);
        helper.addOnClickListener(R.id.iv_search_car);

    }

//    @Override
//    public int getItemCount() {
//        return data.size();
//    }
}
//
//
//    private int HEADER_TYPE = 0;
//    private int ITEM_TYPE = 1;
//    private ArrayList<ObShopBean.PBean.PageItemsBean> data = new ArrayList<>();
//
//    @Override
//    public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
//        super.onViewAttachedToWindow(holder);
//        ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
//        if (lp != null && lp instanceof StaggeredGridLayoutManager.LayoutParams) {
//            StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;
//            p.setFullSpan(holder.getLayoutPosition() == 0);
//        }
//    }
//
//    @Override
//    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//        if (viewType == HEADER_TYPE) {
//            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_ob_header, parent, false);
//            return new HeaderViewHolder(view);
//        }
//        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_search_list, parent, false);
//        return new ItemViewHolder(view);
//    }
//
//    @Override
//    public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
//        switch (holder.getItemViewType()) {
////            case HEADER_TYPE:
////                HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder;
////                break;
////            case ITEM_TYPE:
//                //        helper.setText(R.id.tv_goods_name, item.getTradename());
////        helper.setText(R.id.tv_benifit_kind, item.getDescribed());
////        helper.setVisible(R.id.tv_unit_price, false);
////        helper.setText(R.id.tv_goods_price, item.getPrice() + " 欧花");
////
////        CustomRoundAngleImageView ivGoodsPic = helper.getView(R.id.iv_goods_pic);
////        String imgUrl = "";
////        if (!TextUtils.isEmpty(item.getImg_zt())) {
////            final String[] img_arr = item.getImg_zt().trim().split(",");
////            if (img_arr.length > 0) {
////                imgUrl = img_arr[0];
////            }
////        }
////        GlideUtils.loadRoundImg(mContext, ivGoodsPic, imgUrl, R.mipmap.default_foods_icon, 4);
////
////        helper.addOnClickListener(R.id.ll_item_view);
////        helper.addOnClickListener(R.id.iv_search_car);
//
////                ObShopBean.PBean.PageItemsBean pageItemsBean = data.get(position);
////                ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
////                itemViewHolder.tv_benifit_kind.setText(pageItemsBean.getDescribed());
////                itemViewHolder.tv_goods_name.setText(pageItemsBean.getTradename());
////                itemViewHolder.tv_goods_price.setText(pageItemsBean.getPrice()+" 欧花");
////                itemViewHolder.tv_unit_price.setVisibility(GONE);
////                break;
////        }
//    }
//
////    @Override
////    public int getItemViewType(int position) {
////        if (position == 0) {
////            return HEADER_TYPE;
////        } else {
////            return ITEM_TYPE;
////        }
////    }
////
////    @Override
////    public int getItemCount() {
////        return data.size() + 1;
////    }
//
//    class HeaderViewHolder extends RecyclerView.ViewHolder {
//
//
//        public HeaderViewHolder(View itemView) {
//            super(itemView);
//            ButterKnife.bind(itemView);
//        }
//    }
//
//    class ItemViewHolder extends RecyclerView.ViewHolder {
//        @BindView(R.id.tv_goods_name)
//        TextView tv_goods_name;
//        @BindView(R.id.tv_benifit_kind)
//        TextView tv_benifit_kind;
//        @BindView(R.id.tv_unit_price)
//        TextView tv_unit_price;
//        @BindView(R.id.tv_goods_price)
//        TextView tv_goods_price;
//        @BindView(R.id.iv_goods_pic)
//        CustomRoundAngleImageView iv_goods_pic;
//
//        public ItemViewHolder(View itemView) {
//            super(itemView);
//            ButterKnife.bind(itemView);
//        }
//    }
//}
